<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('数据处理实时反馈列表')" />
    <style>
        .boxes{font-size:15px; color:#000;}
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
         <div class="row">
             <div class="btn-group-sm" id="toolbar" role="group">
                 &nbsp;&nbsp;&nbsp;&nbsp;
                 <a class="btn btn-danger multiple" id="removeButton" shiro:hasPermission="data:feedback:remove">
                     <i class="fa fa-remove"></i> 清除日志
                 </a>
                 <a class="btn btn-warning" id="exportExcel" shiro:hasPermission="data:feedback:export">
                     <i class="fa fa-download"></i> 导出
                 </a>
                 <a class="btn btn-primary btn-rounded btn-sm" onclick="reLoadTable()">
                     <i class="fa fa-refresh"></i>&nbsp;刷新
                 </a>
             </div>
            <div class="col-sm-12">
                <P><textarea rows="20" cols="150" name="disp" readonly  vPosition = "maxVPosition"
                             wrap="physical" class="boxes"
                 id="dsImportfeedbackdata"></textarea></P>
            </div>
             <div style="DISPLAY: none;">
                 <table id="bootstrap-table"></table>
             </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        //var editFlag = [[${@permission.hasPermi('data:feedback:edit')}]];
        //var removeFlag = [[${@permission.hasPermi('data:feedback:remove')}]];
        var prefix = ctx + "data/feedback";
        function removeAll(){
            $.operate.post(prefix + "/removeAll","",function(action){
                $.operate.post(prefix + "/list","",refresh);
                $.modal.alert(action.msg);
            });
        }
        $.operate.post(prefix + "/list","",refresh);
        function refresh(res) {
            var text = "";
            $("#dsImportfeedbackdata").text(text);
            if (res.rows && res.rows.length > 0) {
                $.each(res.rows, function(i, feed){
                    text += feed.trDate+"------->:"+feed.status+"\n\n";//&#10
                });
                $("#dsImportfeedbackdata").text(text);
                scrollText();
            }
        }
        function reLoadTable(){
            $.operate.post(prefix + "/list","",refresh);
        }
        var oTxt=document.getElementById('dsImportfeedbackdata');
        var timer=null;
        var bStop = true;
        function scrollText(){
            if(timer!=null){clearInterval(timer)};
            oTxt.scrollTop=0;
            oTxt.onscroll=null;
            timer=setInterval(function (){
                    oTxt.onscroll=function (){
                        if(!bStop)
                        {
                            if(timer!=null){clearInterval(timer)};
                        }
                        bStop=false;
                    }
                oTxt.scrollTop++;
                bStop = true;
                if(oTxt.scrollTop==oTxt.scrollHeight){
                    clearInterval(timer);
                }
            },5);

        }
        //点击清空按钮，清空所有数据
        $("#removeButton").click(function(){
            //增加提示
            $.modal.confirm("确定要清空数据处理日志?", function() {
                removeAll();
            })
        })
        //点击导出
        $("#exportExcel").click(function(){
            tableInit();
            $.table.exportExcel();
        })
        function tableInit(){
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "数据处理实时反馈",
                columns: [{
                    checkbox: true
                },
                    {
                        field : 'trDate',
                        title : '交易日期'
                    },
                    {
                        field : 'status',
                        title : '状态'
                    },
                    {
                        field : 'reserve',
                        title : '保留'
                    },
                    {
                        title: '操作',
                        align: 'center'
                    }]
            };
            $.table.init(options);
        }
    </script>
</body>
</html>